package com.eachonline.smart.web.interceptor;

import java.util.HashMap;

import javax.servlet.http.HttpSession;

/**
 * 
 * @author wk
 *
 */
public class AppSessionContext {
	private static AppSessionContext instance;
	private HashMap sessionmap;

	private AppSessionContext() {
		sessionmap = new HashMap();
	}

	public static AppSessionContext getInstance() {
		if (instance == null) {
			instance = new AppSessionContext();
		}
		return instance;
	}

	public synchronized void AddSession(HttpSession session) {
		if (session != null) {
			sessionmap.put(session.getId(), session);
		}
	}

	public synchronized void DelSession(HttpSession session) {
		if (session != null) {
			sessionmap.remove(session.getId());
		}
	}

	public synchronized HttpSession getSession(String session_id) {
		if (session_id == null)
			return null;
		return (HttpSession) sessionmap.get(session_id);
	}

}